package com.tom.architect02.p4.day35.simple2;

import com.tom.architect02.p4.day35.retrofit.ErrorHandle;

import rx.Subscriber;

public abstract class BaseSubscriber<T> extends Subscriber<T> {

    @Override
    public void onCompleted() {
    }

    @Override
    public void onError(Throwable e) {
        // e: 网络异常，解析异常，结果处理过程中的异常。
        e.printStackTrace();
        if (e instanceof ErrorHandle.ServiceError) {
            ErrorHandle.ServiceError serviceError = (ErrorHandle.ServiceError) e;
            onError("", serviceError.getMessage());
        } else {
            onError("", "未知异常，");
        }
    }

    protected abstract void onError(String errorCode, String errorMessage);

}
